package com.ilearn.spring.future.test;

import java.util.concurrent.CompletableFuture;

/**
 * @Project: seb-core
 * @Description:
 * @Version 1.0
 * @Throws SystemException:
 * @Author: <li>2018/8/28 lyndon Create 1.0
 * @Copyright (c)2018-2018 中央结算公司，版权所有
 * @Modified By:
 */
public class CompreablefutureDemo {

    public static void main(String[] args) {

        println("当前主线程");
        CompletableFuture.supplyAsync(() -> {
            println("第一步返回\"Hello\"");
            return "Hello";
        }).thenApplyAsync(result -> {
            println("第二步在第一步结果+\",World\"");
            return result + ", World.";
        }).thenAccept(CompreablefutureDemo::println).join();
    }


    public static void println(String message) {
        System.out.printf("[线程: %s] %s\n",
                Thread.currentThread().getName(),
                message);
    }

}
